package com.winning.cqs.pregnantbabycare_cqs_v1.adapter;

import java.util.List;

import com.winning.cqs.pregnantbabycare_cqs_v1.R;
import com.winning.cqs.pregnantbabycare_cqs_v1.domain.HospitalDomain;
import com.winning.cqs.pregnantbabycare_cqs_v1.entity.Hospital;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class BindHospitalAdapter extends ArrayAdapter<Hospital>{
	
	private int resource;
	private List<Hospital> list;

	public BindHospitalAdapter(Context context, int resource,
			List<Hospital> objects) {
		super(context, resource, objects);
		// TODO Auto-generated constructor stub
		this.resource = resource;
		list = objects;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View view = null;
		Hospital hospital = getItem(position);
		ViewHolder holder = null;
		if (convertView == null) {
			view = LayoutInflater.from(getContext()).inflate(resource, null);
			holder = new ViewHolder();
			holder.tv_hospital = (TextView) view.findViewById(R.id.item_bindhospital_tv_hospital);
			view.setTag(holder);
			
		}else {
			view = convertView;
			holder = (ViewHolder)view.getTag();
		}
		holder.tv_hospital.setText(hospital.getYymc());
		
		return view;
	}
	
	
	static class ViewHolder{
		public TextView tv_hospital;
	}

}
